using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public sealed class ActionMoveController 
{

    private Dictionary<ActionMoveTime, ActionMove> actionMoves = new Dictionary<ActionMoveTime, ActionMove>();

    public ActionMoveController()
    {
        Initialize();
    }

    /// <summary>
    /// 初始化
    /// </summary>
    private void Initialize()
    {
        foreach (ActionMoveTime type in Enum.GetValues(typeof(ActionMoveTime)))
        {
            actionMoves[type] = new ActionMove();
        }
    }

    /// <summary>
    /// 添加监听器
    /// </summary>
    public void AddListener(ActionMoveTime actionMoveType, Action<SkillBase> listener)
    {

        if (actionMoves.ContainsKey(actionMoveType))
        {
            actionMoves[actionMoveType].AddListener(listener);
        }
        
    }

    /// <summary>
    /// 移除监听器
    /// </summary>
    public void RemoveListener(ActionMoveTime actionMoveType, Action<SkillBase> listener)
    {
        if (actionMoves.ContainsKey(actionMoveType))
        {
            actionMoves[actionMoveType].RemoveListener(listener);
        }
    }

    /// <summary>
    /// 触发监听器
    /// </summary>
    public void TriggerActionMove(ActionMoveTime actionMoveType, SkillBase action)
    {
        if (actionMoves.ContainsKey(actionMoveType))
        {
            actionMoves[actionMoveType].Trigger(action);
        }
    }

}
